import type { Carousel01Item } from '@/api/designer/model'

/** 当`opts.mode`为'multiple'时, 仅包含`jumpType`字段 */
export type OpenData = Omit<Carousel01Item, 'picture' | 'title' | 'description' | 'sort'>
interface OpenCallbackCanceledMeta {
  applied: false
  value: null
  /** @only mode === 'multiple' */
  selectedItems?: unknown[]
}
interface OpenCallbackAppliedMeta {
  applied: true
  /** 当`opts.mode`为'multiple'时, 仅包含`jumpType`字段 */
  value: OpenData
  /** @only mode === 'multiple' */
  selectedItems?: unknown[]
}
export type OpenCallbackMeta = OpenCallbackCanceledMeta | OpenCallbackAppliedMeta
export type OpenCallback = (meta: OpenCallbackMeta) => void
export type SelectedKeyType = string | number
export interface OpenOpts {
  /** 
   * 是否单选模式, 如多选侧边栏目不可切换
   * @default "single"
   */
  mode?: 'single' | 'multiple'
  /** 
   * 默认选择的keys
   * @default []
   */
  selectedKeys?: SelectedKeyType[]
}
export interface Exposed {
  /**
   * @param data 当`opts.mode`为'multiple'时, 仅包含`jumpType`字段
   */
  open: (data: OpenData, callback: OpenCallback, opts?: OpenOpts) => Promise<void>
}
